Repository navigation
feat(cli): pass RC_COMMAND_PREFIX environment variable to add-ons (#17) - #26
Merged
colinjlacy merged 1 commit intoNov 27, 2026
Conversation
colinjlacy
approved these changes
Nov 27, 2026
colinjlacy
left a comment
Contributor
There was a problem hiding this comment.
This is great! I love that it doesn't break anything in the profilers if there's a version mismatch between them. If you had gone with a flag or argument, that would have caused interfacing problems. Very nicely done!!! 😁👍
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Part of #17.
When
rcinvokes a language profiler add-on (TypeScript, Java, Python), it now passesRC_COMMAND_PREFIXin the subprocess environment set to the dynamic command path (usingcmd.CommandPath(), e.g.,rc profile typescript).This enables add-ons to format their usage diagnostics and command suggestions using the command the user actually ran, rather than naming their standalone binary.
Changes
internal/cli/plugins.go(newLanguageCommand):RC_COMMAND_PREFIX=<cmd.CommandPath()>intoprocess.Spec.Envby appending toos.Environ().cmd.CommandPath()dynamically rather than hardcoded strings, ensuring subcommands, aliases, or binary name variations are accurately reflected.--version --jsonmetadata probe remains untouched (runs with inherited environment).internal/cli/plugins_test.go:TestAddOnReceivesItsArgumentsUnchangedAndItsOutputPassesThrough,TestJavaAddOnReceivesItsArgumentsUnchangedAndItsOutputPassesThrough, andTestPythonAddOnReceivesItsArgumentsUnchangedAndItsOutputPassesThroughverifyingRC_COMMAND_PREFIXis populated with the correct prefix for TypeScript, Java, and Python add-ons.docs/language-profilers.md:RC_COMMAND_PREFIXenvironment variable contract for profiler add-on authors.Notes for Reviewers
rc-cliside of Tell add-ons how they were invoked, so their messages name the right command #17. Separate follow-ups in the respective profiler repos will consume this variable in their usage formatters.RC_COMMAND_PREFIXfollows the proposal in Tell add-ons how they were invoked, so their messages name the right command #17; happy to adjust if the contract/spec discussion settles on a different name.Verification
go test -v ./internal/cli -run "^Test(AddOn|JavaAddOn|PythonAddOn)"passed.go vet ./internal/cli/...passed cleanly.